<?php

namespace App\Jobs;

use App\Facades\AliyunCdn;
use App\Models\DomainPool;

class CreateAilyunCdn extends BaseJob
{
    public string $queue = 'aliyun';

    public function __construct(protected DomainPool $pool)
    {
    }

    public function handle(): void
    {
        $this->pool->objectStorageService->aliyun->initClient();

        AliyunCdn::aliyun($this->pool->objectStorageService->aliyun)
            ->store($this->pool->domain, $this->pool->objectStorageService->bucket);

        # 等一会能获取到DCDN的CNAME信息，再解析
        CreateAliyunDns::dispatch($this->pool)
            ->delay(120);
    }
}
